<template>
  <view class="content">
    <uni-nav-bar
      title="余额明细"
      color="#fff"
      backgroundColor="transparent"
      :border="false"
      :statusBar="true"
      :fixed="true"
      @clickLeft="$c.back()"
    >
      <view class="uni-nav-bar-l-icon" slot="left">
        <view class="uni-nav-bar-l-icon-left icon">
          <image :src="$img('/static/img2/cc20.png')" lazy-load></image>
        </view>
      </view>
    </uni-nav-bar>

    <view class="tab-list">
      <view
        @click="getlist(i)"
        v-for="(item, i) in arr"
        :key="i"
        class="tab-list-item c_bg"
        :class="{
          active: show == i
        }"
        :style="{
          backgroundImage: `url(${$img('/static/img2/cc147.png')})`
        }"
      >
        {{ item }}
      </view>
    </view>

    <!-- <view class="head">
      <view class="qiehuan">
        <view @click="getlist(i)" v-for="(v, i) in arr" :key="i">
          <view :class="show == i ? 'xzs' : 'wzs'">{{ v }}</view>
          <view class="qiehuan_line" v-if="show == i">
          </view>
        </view>
      </view>
    </view> -->
    <!-- 内容 -->
    <mescroll-body
      ref="mescrollRef"
      @init="mescrollInit"
      :down="downOption"
      @down="downCallback"
      @up="upCallback"
    >
      <view class="coupon">
        <view
          v-for="(item, index) in listData"
          :key="index"
          class="coupon_item"
        >
          <view class="coupon_item_1">
            <view>{{ item.content }}</view>
            <view>{{ item.addtime }}</view>
          </view>
          <view class="coupon_r">{{ item.change_money }}</view>
        </view>
      </view>
    </mescroll-body>
  </view>
</template>

<script>
export default {
  data() {
    return {
      z_imgPath: this.$z_img2 + 'mine/',
      statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
      arr: ['全部', '收入', '支出', '兑换'],
      show: 0,
      listData: [],

      // 是否显示参与
      downOption: {
        auto: false
      }
    }
  },
  onLoad(e) {
    // setTimeout(() => {
    //   this.listData=[
    //     {
    //       content:'哈哈哈哈哈哈哈哈哈',
    //       addtime:'2333-23-23 23:23:23',
    //       change_money:233
    //     }
    //   ]
    // }, 1000);
  },
  methods: {
    back() {
      uni.navigateBack()
    },
    getlist(v) {
      this.show = v
      this.aixuanArr = []
      this.mescroll.resetUpScroll()
    },

    /*下拉刷新的回调 */
    downCallback() {
      this.mescroll.resetUpScroll()
    },
    /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
    upCallback(page) {
      //联网加载数据
      this.loadData(page.num)
    },
    loadData(pageNo) {
      // 模拟接口
      let that = this
      that.req({
        url: 'profitMoney',
        Loading: true,
        data: {
          page: pageNo,
          type: that.show
        },
        success(res) {
          that.mescroll.endByPage(res.data.data.length, res.data.last_page)
          if (pageNo == 1) {
            that.listData = res.data.data
          } else {
            that.listData = that.listData.concat(res.data.data)
          }
        }
      })
    }
  }
}
</script>

<style lang="scss">
.coupon_r > image {
  width: 32rpx;
  height: 32rpx;
  margin-left: 10rpx;
}

.coupon_r {
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 30rpx;
  color: #e40d1d;
}

.coupon_item_1 > view:nth-of-type(2) {
  font-size: 24rpx;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 10rpx;
}

.coupon_item_1 > view:nth-of-type(1) {
  font-size: 28rpx;
  // font-weight: bold;
  color: #ffffff;
}

.coupon_item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30rpx 0;
  box-sizing: border-box;

  position: relative;
  border-bottom: 1px solid #333;
}

.coupon {
  width: 690rpx;
  margin: 20rpx auto;
  box-sizing: border-box;
}

.qiehuan {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16rpx;
  width: 400rpx;
}

.qiehuan_line {
  margin: -10rpx auto;
  width: 30rpx;
  height: 20rpx;
  border-bottom: 4rpx solid #70ede8;
  border-radius: 2rpx;
}

.qiehuan_line > image {
  width: 30rpx;
  height: 20rpx;
}

.qiehuan > view {
  flex: 1;
  text-align: center;
}

.wzs {
  font-size: 34rpx;
  color: rgba(255, 255, 255, 0.6);
}

.xzs {
  font-size: 34rpx;
  color: #ffffff;
}

.header {
  width: 750rpx;
  /* height: 176rpx; */
  padding-bottom: 30rpx;
  background: #222222;
  font-size: 28rpx;
  color: #333333;
  box-sizing: border-box;
  position: fixed;
  /* #ifdef MP */
  top: 0;
  /* #endif */
  /* #ifndef MP */
  top: 88rpx;
  /* #endif */
  z-index: 15;
}

.content {
  width: 100vw;
  min-height: 100vh;
  box-sizing: border-box;
  color: #fff;

  .head {
    position: fixed;
    top: 0;
    z-index: 20;

    .header_title {
      height: 70rpx;
      line-height: 70rpx;
      width: 100%;
      box-sizing: border-box;
      font-weight: bold;
      display: flex;
      align-items: center;
      padding-left: 30rpx;
      box-sizing: border-box;

      > view:nth-of-type(1) {
        display: flex;
        align-items: center;
      }

      > view:nth-of-type(2) {
        width: 520rpx;
        text-align: center;
        /* margin: auto; */
      }

      image {
        width: 48rpx;
        height: 48rpx;
      }
    }
  }
}

.tab-list {
  display: flex;
  justify-content: space-between;
  padding: 30rpx;

  .tab-list-item {
    width: 150rpx;
    height: 76rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    filter: grayscale(1);

    font-family: 光良酒-干杯体, 光良酒-干杯体;
    font-weight: 400;
    font-size: 28rpx;
    color: #ffffff;
    text-shadow: 0 0 3px #000000, 0 0 3px #000000, 0 0 3px #000000,
      0 0 3px #000000;

    &.active {
      filter: grayscale(0);
    }
  }
}
</style>
